<?php

namespace App\Http\Controllers;

use App\Measures;
use Illuminate\Http\Request;
use Illuminate\Support\Facades\Log;

class CallbackController extends Controller
{
    public function store(Request $request)
    {
        Log::info(array_keys($request->all())[0]);
        if( !empty(array_keys($request->all())))
        {
            $resString = array_keys($request->all())[0];

            $humidity = explode(',',$resString)[0];
            $temperature = explode(',',$resString)[1];
            $measureObj = new Measures();
            $measureObj->humidity = $humidity;
            $measureObj->temperature = $temperature;
            $measureObj->save();
            return 'ok' . $humidity . ',' .$temperature;
        }

        return ['code'=>0,'msg'=>'成功'];
    }
}
